Skip to content

Conversation

@dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Mar 13, 2023

If the channel is closed before flatMap is executed, all ChannelHandler are removed and TLSEventsHandler is therefore not present either. We need to tolerate this even though it is very rare.

Testing ideas welcome.

Fixes #670

If the channel is closed before flatMap is executed, all ChannelHandler are removed and `TLSEventsHandler` is therefore not present either. We need to tolerate this even though it is very rare.

Testing ideas welcome.

Fixes swift-server#670
channel.pipeline.removeHandler(tlsEventHandler).map { (channel, negotiated) }
}
} catch {
precondition(channel.isActive == false, "if the channel is still active then TLSEventsHandler must be present but got error \(error)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this precondition is particularly wise: the connection pool will appropriately handle this. Let's drop it to assert instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d0d1cee

@Lukasa
Copy link
Collaborator

Lukasa commented Mar 14, 2023

Can you clean up soundness?

@dnadoba dnadoba enabled auto-merge (squash) March 14, 2023 10:31
@dnadoba dnadoba merged commit 423fd0b into swift-server:main Mar 14, 2023
@dnadoba dnadoba deleted the dn-fix-early-close-crash branch March 14, 2023 11:05
@dnadoba dnadoba added 🔨 semver/patch No public API change. and removed 🆕 semver/minor Adds new public API. labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error: 'try!' expression unexpectedly raised an error: NIOCore.ChannelPipelineError.notFound

2 participants